package com.ysh.ioc.controller;

import com.ysh.ioc.config.UserConfig;
import com.ysh.ioc.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;

@Controller
public class HelloController {
    //属性注入
    //@Autowired
    //private UserService userService;

    //构造方法注入
    /*private UserService us;

    public HelloController() {
    }
    @Autowired
    public HelloController(UserService userService) {
        this.us = userService;
    }*/

    //setter方法注入
    private UserService us;
    private UserConfig uc;

    @Autowired
    public void setUs(UserService us) {
        this.us = us;
    }
    @Autowired
    public void setUc(UserConfig uc) {
        this.uc = uc;
    }

    public void print(){
        System.out.println("do Controller");
        us.print();
        uc.print();
    }
}
